package com.glsc.ngateway.common.base.utils;

import org.springframework.util.StringUtils;

/**
 * @author: qiyr
 * @date: 2022/6/8 10:18
 * @description: 报表导出文件类型枚举类
 */
public enum ReportExportFileTypeEnum {

    XLSX("xlsx", "Excel(.xlsx)"),

    XLS("xls", "Excel(.xls)"),

    DOCX("docx", "Word(.docx)"),

    PDF("pdf", "PDF"),

    PNG("png", "PNG");

    private String type;
    private String name;

    ReportExportFileTypeEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isValid(String type) {
        if (!StringUtils.hasText(type)) {
            return false;
        }
        ReportExportFileTypeEnum[] enums = ReportExportFileTypeEnum.values();
        for (ReportExportFileTypeEnum typeEnum : enums) {
            if (typeEnum.getType().equalsIgnoreCase(type)) {
                return true;
            }
        }
        return false;
    }

}
